<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class News extends MY_Controller {

	function __construct()
	{
		parent::__construct();
		
		
	}
    
    function new_index()
    {
        $left = array();
        $right = array();
        $u = $this->session->current_user();
        $targets = false;
        if($u)
        {
           $targets = OxTarget::from_user_id($u->iduser); 
        }
        if($targets)
        {
            for($i = 0; $i < count($targets);$i++)
            {
                $a = array('name'=>$targets[$i]->name, 
                    "articles"=>$this->articles->get_articles_for_target_by_id($targets[$i]->idtargets, 4),
                    'target'=>$targets[$i]);
                if($i%2)
                {
                    $left[] = $a;
                }
                else
                {
                    $right[] = $a;
                }
            }
        }
        else
        {
            $left = array();
            $left[] = array('name'=>'Top Global News', 
                "articles"=>$this->articles->get_articles_for_target_by_id(1, 15),
                "target"=>OxTarget::from_id(1));
            $right = array();
            $right[] = array('name'=>'Top Local News', 
                "articles"=>$this->articles->get_articles_for_target_by_id(4, 14),
                "target"=>OxTarget::from_id(4));
        }
        $data1 = array('targets' => $left);
        $data2 = array('targets' => $right);
        
		$this->ShowHeader('', array(), array(), false);
		$this->load->view('main_page_1', $data1);
		$this->load->view('main_page_1', $data2);
		$this->ShowFooter();
        

    }

	function index()
	{
        $this->new_index(); return;
		/*
	    $data['query'] = $this->articles->get_ten_random_entries();
        
	    $b = array ();
		$b[] = array ("box_view"=>"article",
                        "style"=>"", "title"=>"News Flash", 
				        "article"=>OxArticle::get_random_article());
        $b[] = array ("box_view"=>"article",
                        "style"=>"background:#eecccc", "title"=>"Featured Article", 
				        "article"=>OxArticle::get_random_article());
        $b[] = array ("style"=>"background:#aacccc", "title"=>"Request an interview with...", 
				        "text"=>'Yuo can request an interview with a person you find important to be interviewed. Read more about <a href="'.site_url('info/10').'">Oximity Interviews.</a>');
        $b[] = array ("box_view"=>"article",
                        "style"=>"", "title"=>"Local Flash", 
				        "articles"=>OxArticle::get_random_article());
		
        $data2['boxes'] = $b;
                 
		$this->ShowHeader();
		$this->load->view('main_page', $data);
		$this->load->view('box_frame', $data2);
		$this->ShowFooter();
         * 
         */
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */